import time
import Page
from Page import Launcher
from Base.Base import Base
from selenium.webdriver.common.by import By


class LauncherAccountSelectPage(Base):
    """
    桌面账户选择页页面

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.account_home_btn = (By.XPATH, Launcher.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.account_back_btn = (By.XPATH, Launcher.RESOURCE_ID.format('ivBack'))

        # 账户页标题
        self.account_select_title_text = (By.XPATH, Launcher.RESOURCE_ID.format("textView8") )

        # 账户头像
        self.account_picture_icon = (By.XPATH, Launcher.account_picture_pic.format(""))

        # 账户性别
        self.account_gender_icon = (By.XPATH, Launcher.account_gender_icon.format(""))

        # 账户名称
        self.account_name_text = (By.XPATH, Launcher.account_name_text.format(""))

        # 账户选中框
        self.account_check_box_icon = (By.XPATH, Launcher.account_select.format(""))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.account_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.account_back_btn)

    def get_select_title(self):
        """
        获取账户切换页面标题

        :return:获取元素
        """
        return self.find_element_o(self.account_select_title_text)

    def get_picture(self, index=1):
        """
        获取账户头像

        :return:获取元素
        """
        self.account_picture_icon = (By.XPATH, Launcher.account_picture_pic.format(index))
        return self.find_element_o(self.account_picture_icon)

    def get_gender(self, index=1):
        """
        获取账户性别

        :return:获取元素
        """
        self.account_gender_icon = (By.XPATH, Launcher.account_gender_icon.format(index))
        return self.find_element_o(self.account_gender_icon)

    def get_name(self, index=1):
        """
        获取账户名称

        :return:获取元素
        """
        self.account_name_text = (By.XPATH, Launcher.account_name_text.format(index))
        return self.find_element_o(self.account_name_text)

    def click_check_box(self, index=1):
        """
        点击账户选中框

        :return:None
        """
        self.account_check_box_icon = (By.XPATH, Launcher.account_select.format(index))
        self.click_element(self.account_check_box_icon)

    def is_display_account_select(self):
        """
        是否进入账户选择页面
        :return:
        """
        return self.is_display(self.account_select_title_text)
